package domain;

import java.util.HashSet;
import java.util.Set;

public class ContactGroup {

	private int groupId;
	private String groupName;
	private Set<Contact> contacts;
	private long version;

	public ContactGroup() {
		contacts = new HashSet<Contact>();
	}

	public int getGroupId() {
		return groupId;
	}

	public void setGroupId(int groupeId) {
		this.groupId = groupeId;
	}

	public String getGroupName() {
		return groupName;
	}

	public void setGroupName(String groupName) {
		this.groupName = groupName;
	}

	public Set<Contact> getContacts() {
		return contacts;
	}

	public void setContacts(Set<Contact> contacts) {
		this.contacts = contacts;
	}
	
	public long getVersion() {
		return version;
	}

	public void setVersion(long version) {
		this.version = version;
	}

	
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		// TODO voir si on décommente
//		result = prime * result + ((contacts == null) ? 0 : contacts.hashCode());
		result = prime * result + groupId;
		result = prime * result
				+ ((groupName == null) ? 0 : groupName.hashCode());
		result = prime * result + (int) (version ^ (version >>> 32));
		return result;
	}

	
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		ContactGroup other = (ContactGroup) obj;
		if (contacts == null) {
			if (other.contacts != null)
				return false;
		}
		if (groupId != other.groupId)
			return false;
		if (groupName == null) {
			if (other.groupName != null)
				return false;
		} else if (!groupName.equals(other.groupName))
			return false;
		if (version != other.version)
			return false;
		return true;
	}
}
